<template>
  <div class="u-p-20">
    <el-card shadow="never">
      <div slot="header">
        <b class="u-f-16">
          <span v-if="objForm.id">编辑</span>
          <span v-else>添加</span>用户协议
        </b>
        <div class="u-right u-5mt">
          <el-button
            type="success"
            size="small"
            icon="el-icon-document-checked"
            @click="submitForm('objForm')"
            v-if="hasPerm('userProtocolEdit')"
          >提交保存</el-button>
          <el-button size="small" icon="el-icon-back" @click="$router.go(-1)">返回</el-button>
        </div>
      </div>
      <el-form :model="objForm" :rules="rules" ref="objForm" label-width="100px" class="u-form">
        <el-form-item label="协议类型">
          <el-select v-model="objForm.type" placeholder="请选择协议类型">
            <el-option label="注册协议" value="1"></el-option>
            <el-option label="隐私协议" value="2"></el-option>
            <el-option label="动态发布声明" value="3"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="协议标题">
          <el-input v-model="objForm.title" placeholder="协议标题"></el-input>
        </el-form-item>
          <el-form-item label="协议版本">
          <el-input v-model="objForm.versions" placeholder="协议版本（1.0.0）"></el-input>
        </el-form-item>
        <el-form-item label="是否启用">
          <el-switch
            v-model="objForm.status"
            active-color="#13ce66"
            :active-value="1"
            inactive-color="#666"
            :inactive-value="2"
          ></el-switch>
        </el-form-item>
        <el-form-item label="内容">
          <wangeditor :content="objForm.content" @getHtml="getHtml"></wangeditor>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import commonEdit from "@/mixins/common-edit";
import Wangeditor from "@/components/wangeditor/index";
export default {
  components: {
    Wangeditor,
  },
  mixins: [commonEdit],
  data() {
    return {
      apiName: "userProtocol",
      backRoute: "userProtocolIndex", //成功跳转地址
      objForm: {
        id: "",
        type: "1", //协议类型 1注册协议
        title: "", //协议标题
        versions:"1.0.0",
        content: "", //协议内容
        status: "", //1启用 2关闭
      },
    };
  },
  methods: {
    getHtml(val) {
      this.objForm.content = val;
    },
    afterGetInfo() {
      this.objForm.type = this.objForm.type + "";
    },
  },
};
</script>
